<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>创建试卷</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    {load href="/static/css/bootstrap.min.css" /} 
    {load href="/static/css/mycss.css" /} 
    {load href="/static/js/jquery.js" /}
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    {load href="/static/js/bootstrap.min.js" /}
    {load href="/static/uedit/ueditor.config.js" /}
    {load href="/static/uedit/ueditor.all.min.js" /}
    {load href="/static/uedit/lang/zh-cn/zh-cn.js" /}

    <script type="text/javascript">

        UE.getEditor("myEditor");
        UE.getEditor("myEditor2");

    </script>
</head>
<body>
<div class="container">
    <div class="row">
        <div>
            <span class="glyphicon glyphicon-plus pull-left">&nbsp;</span>
            <h4>创建试卷</h4>
            <h4><a href="{:url('admin/Index/index')}">返回首页</a></h4>
            <span class="pull-right close1">×</span>
            <hr>
        </div>
    </div>
    <form action="{:url('admin/Paper/doAdd')}" method="post">
        <input type="hidden" name="id" value="{$id}" >
        <div class="row">
            <div  class="col-xs-2" >
                <label class="pull-right" >试卷名称</label>
            </div>
            <div class="col-xs-8">
                <input type="text" class="form-control" name="title" required="" value="{$paper.title}">
            </div>
        </div>
        <div class="row ma-t15">
            <div  class="col-xs-2" >
                <label class="pull-right">试卷说明</label>
            </div>
            <div class="col-xs-8">
                <textarea style="height:200px;" name="instruction" id="myEditor" required="">{$paper.instruction}</textarea>
            </div>
        </div>
        <div class="row ma-t15">
            <div  class="col-xs-2" >
                <label class="pull-right">时间限制</label>
            </div>
            <div class="col-xs-8">
                <div style="width:300px;float:left;">
                    <input type="text" name="timelimit" class="form-control"  required="" value="{$paper.timelimit}">
                </div>&nbsp;&nbsp;&nbsp;&nbsp;<span style="line-height:34px;">分钟</span>

            </div>
        </div>
        <div class="row ma-t15">
            <div  class="col-xs-2" >
                <label class="pull-right">生成方式</label>
            </div>
            <div class="col-xs-10">
                <input type="radio" name="createway" checked="" value="1" {if condition="$paper['createway'] == 1"} checked {/if}>&nbsp;随机生成&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input class="ml30" type="radio" name="createway" value="0" {if condition="$paper['createway'] == 0"} checked {/if}>&nbsp;按难易度生成
            </div>
        </div>
        <div class="row ma-t15">
            <div  class="col-xs-2" >
                <label class="pull-right">试卷难度</label>
            </div>
            <div class="col-xs-10">
                <select name="degree">
                    <option value="1" {if condition="$paper['degree'] == '1'"} selected {/if}>简单</option>
                    <option value="2" {if condition="$paper['degree'] == '2'"} selected {/if}>一般</option>
                    <option value="3" {if condition="$paper['degree'] == '3'"} selected {/if}>困难</option>
                </select>
            </div>
        </div>
        <div class="row ma-t15">
            <div  class="col-xs-2" >
                <label class="pull-right">题目设置</label>
            </div>
            <div class="col-xs-10">
                <div class="row">
                    <div class="col-xs-2"><span class="glyphicon glyphicon-move text-primary"></span>单选题</div>
                    <div class="col-xs-2">题目数量：<span class="w50 dis_il"><input type="number" min="0" class="form-control" name="singlenum" onkeyup="compute(this)" value="{$paper['singlenum']}" max="{$singlenum}"></span></div>
                    <div class="col-xs-2">题目总分值：<span class="w50 dis_il"><input type="text" class="form-control" value="{$paper['singlenum']*2}" name="ascore[]" ></span></div>
                </div>
                <div class="row mt10">
                    <div class="col-xs-2"><span class="glyphicon glyphicon-move text-primary"></span>多选题</div>
                    <div class="col-xs-2">题目数量：<span class="w50 dis_il"><input type="number" min="0" class="form-control" name="mulnum" onkeyup="compute(this)" value="{$paper['mulnum']}"  max="{$mulnum}"></span></div>
                    <div class="col-xs-2">题目总分值：<span class="w50 dis_il"><input type="text" class="form-control" name="ascore[]" value="{$paper['mulnum']*3}"></span></div>
                    <div class="col-xs-6">漏选分值：<span class="w50 dis_il"><input type="text" class="form-control" name="mulpoint"  required="" value="{$paper['mulpoint']}"></span><span class="text-danger"> 缺一道题</span>
                    </div>
                </div>
                <div class="row mt10">
                    <div class="col-xs-2"><span class="glyphicon glyphicon-move text-primary"></span>不定项选择题</div>
                    <div class="col-xs-2">题目数量：<span class="w50 dis_il"><input type="number" min="0" class="form-control" name="idenum" onkeyup="compute(this)" value="{$paper['idenum']}" max="{$idenum}"></span></div>
                    <div class="col-xs-2">题目总分值：<span class="w50 dis_il"><input type="text" class="form-control" name="ascore[]" value="{$paper['idenum']*4}"></span></div>
                    <div class="col-xs-6">漏选分值：<span class="w50 dis_il"><input type="text" class="form-control" name="idepoint"  required="" value="{$paper['idepoint']}"></span>
                    </div>
                </div>
                <div class="row mt10">
                    <div class="col-xs-2"><span class="glyphicon glyphicon-move text-primary"></span>填空题</div>
                    <div class="col-xs-2">题目数量：<span class="w50 dis_il"><input type="number" min="0" class="form-control" name="fillnum" onkeyup="compute(this)" value="{$paper['fillnum']}" max="{$fillnum}"></span></div>
                    <div class="col-xs-2">题目总分值：<span class="w50 dis_il"><input type="text" class="form-control" name="ascore[]" value="{$paper['fillnum']*1}"></span></div>
                </div>
                <div class="row mt10">
                    <div class="col-xs-2"><span class="glyphicon glyphicon-move text-primary"></span>判断题</div>
                    <div class="col-xs-2">题目数量：<span class="w50 dis_il"><input type="number" min="0" class="form-control" name="judgenum" onkeyup="compute(this)" value="{$paper['judgenum']}" max="{$judgenum}"></span></div>
                    <div class="col-xs-2">题目总分值：<span class="w50 dis_il"><input type="text" class="form-control" name="ascore[]" value="{$paper['judgenum']*1}"></span></div>
                </div>
                <div class="row mt10">
                    <div class="col-xs-2"><span class="glyphicon glyphicon-move text-primary"></span>简答题</div>
                    <div class="col-xs-2">题目数量：<span class="w50 dis_il"><input type="number" min="0" class="form-control" name="shortnum" onkeyup="compute(this)" value="{$paper['shortnum']}" max="{$shortnum}"></span></div>
                    <div class="col-xs-2">题目总分值：<span class="w50 dis_il"><input type="text" class="form-control" name="ascore[]" value="{$paper['shortnum']*10}"></span></div>
                </div>
            </div>
        </div>


        <br />
        <br />
        <hr>

        <input type="button" class="btn btn-default co-gray pull-right ma-l20" value="取消">
        <input type="submit" class="btn btn-primary pull-right" value="确定">
    </form>
</div>

</body>
<script type="text/javascript">
    function compute(obj){
        //js比较大小需要先将字符串转换为数字
        var num = $(obj).val();
        num = Number(num)
        var type = $(obj).attr("name");
        var max = $(obj).attr("max");
        max = Number(max)
        if (num > max) {
           $(obj).val(''); 
           $(obj).parent().parent().next().find("input").val('');
           return false; 
        }
        // console.log('type');
        // console.log('num');
        switch(type)
        {
        case 'singlenum':
          var score = num*2;
          break;
        case 'mulnum':
          var score = num*3;
          break;
        case 'idenum':
          var score = num*4;
          break;
        case 'fillnum':
          var score = num*1;
          break;
        case 'judgenum':
          var score = num*1;
          break;
        case 'shortnum':
          var score = num*10;
          break;
        default:
          break;
        }
        $(obj).parent().parent().next().find("input").val(score);
    }

</script>
</html>